using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Xml.Serialization;
using System.Text.RegularExpressions;


namespace WOWEquipOptimizer
{
    [XmlInclude(typeof(Armor)), XmlInclude(typeof(Gem)), XmlInclude(typeof(WeaponSkill)), XmlInclude(typeof(Ring)), XmlInclude(typeof(Trinket)), XmlInclude(typeof(Weapon))]
    public abstract partial class Item
    {
        public static int FilterItemLevelBelow = 0;
        public static int FilterItemLevelAbove = -1;
        public static int MaxItemLevel = -1;
        public static List<string> FilterArea = new List<string>();
        public static List<ItemSource> FilterSource = new List<ItemSource>();
        public static List<string> AllAreas = new List<string>();
        public bool filterItem()
        {
            if (Level < FilterItemLevelBelow) return true;
            if (Level > FilterItemLevelAbove) return true;
            foreach (string dungeon in FilterArea)
            {
                if (m_AreaName.Contains(dungeon))
                {
                    return true;
                }
            }
            foreach (ItemSource source in FilterSource)
            {
                if(m_Source == source)
                {
                    return true;
                }
            }
            return false;
        }
        public static void InitFilter()
        {
            int lvl = 0;
            foreach (Item item in Database.Items)
            {
                if (item.Level > lvl) lvl = item.Level;
                foreach (string area in item.m_AreaName)
                {
                    if (!AllAreas.Contains(area))
                    {
                        AllAreas.Add(area);
                    }
                }
            }
            MaxItemLevel = lvl;
            FilterItemLevelAbove = lvl;
            AllAreas.Remove("Unknown");
        }
    }
}
